﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Collections;

using System.Text;
using System.IO;
using System.Xml;
using System.Data;

using Gift.Model;
using Gift.DAL;


public partial class cn_member_center_my_points_for_order : System.Web.UI.Page
{
    protected string orderNo = "";

    readonly DALPointsForOrder thePointsForOrder = new DALPointsForOrder();
    readonly DALPointsFor thePointsFor = new DALPointsFor();

    // Methods
    protected StringBuilder GetUserOrder()
    {
        StringBuilder builder = new StringBuilder();
        try
        {
            if (this.Session["user"] == null)
            {
                return builder;
            }
            if (base.Request.QueryString["orderNo"] != null)
            {
                this.orderNo = base.Request.QueryString["orderNo"];
            }
            DataTable orderByOrderUserAndOrderNo = this.thePointsForOrder.GetOrderByOrderUserAndOrderNo((this.Session["user"] as tbUser).id, this.orderNo);
            if (orderByOrderUserAndOrderNo.Rows.Count > 0)
            {
                foreach (DataRow row in orderByOrderUserAndOrderNo.Rows)
                {
                    builder.AppendLine("<tr>");
                    builder.AppendLine(string.Concat(new object[] { "<td style=\"height: 32px\"><a href=\"points_for_order_info.html?orderNo=", row["orderNo"], "\">", row["orderNo"], "</a></td>" }));
                    string str = this.thePointsFor.GetModel(Convert.ToInt32(row["goodsEntitys"])).name;
                    builder.AppendLine(string.Concat(new object[] { "<td style=\"height: 32px;text-align:left\"><a href=\"points_for_order_info.html?orderNo=", row["orderNo"], "\">", str, "</a></td>" }));
                    builder.AppendLine("<td style=\"height: 32px\">" + Convert.ToDateTime(row["createTime"]).ToString("yyyy/MM/dd") + "</td>");
                    builder.AppendLine("<td style=\"height: 32px\">" + row["orderIntegral"] + "</td>");
                    string str2 = "";
                    string str3 = "";
                    switch (Convert.ToInt32(row["payStatus"]))
                    {
                        case 0:
                            str2 = "[未支付]";
                            break;

                        case 1:
                            str2 = "[已支付]";
                            break;
                    }
                    switch (Convert.ToInt32(row["deliveryStatus"]))
                    {
                        case 0:
                            str3 = "[未发货]";
                            break;

                        case 1:
                            str3 = "[已发货]<br /><a href=\"javascript:return false;\" onclick=\"aConfirm('" + row["orderNo"] + "');\">[确认收货]</a>";
                            break;

                        case 2:
                            str3 = "[已收货]";
                            break;
                    }
                    builder.AppendLine("<td style=\"height: 32px\">" + str2 + "<br />" + str3 + "</td>");
                    builder.AppendLine("</tr>");
                }
                return builder;
            }
            builder.AppendLine("<tr>");
            builder.AppendLine("<td colspan=\"5\" style=\"text-align: center; color: #ff0000;\">没有找到任何记录</td>");
            builder.AppendLine("</tr>");
        }
        catch
        {
        }
        return builder;
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        if (HttpContext.Current.Session["user"] == null)
        {
            base.Response.Redirect("/cn/web_login.html?ru=" + HttpContext.Current.Request.Url.PathAndQuery.Replace("aspx", "html"));
        }
    }

}